package com.yien.springstudy.trycatch;

/**
 * 多层try catch
 *
 * @author Miaoxiong Fan
 * @since version
 */

public class MultiTryCatch {

    public static void main(String[] args) {
        returnWithFinally();
    }

    public static void multiFinally() {
        System.out.println("第一层");
        try {
//            int result1 = 1/0;
            for (int i = 0; i < 5; i++) {
                try {
                    System.out.println("第二层");
                }catch (Exception e) {

                }finally {
                    System.out.println("第二层finally");
                }
            }
//                int result2 = 1/0;
        }catch (Exception e) {

        }finally {
            System.out.println("第一层finally");
        }
    }

    public static void returnWithFinally() {
        try {
            System.out.println("主业务部门");
            int flag = 0;
            if(flag == 0) {
                return;
            }
            System.out.println("主业务处理其他事务");
        }catch (Exception e) {
            System.out.println("捕获异常");
        }finally {
            System.out.println("finally 业务部分");
        }
    }

}
